package com.lvkerry.orderfood.entity;

import javax.persistence.*;
import java.io.Serializable;

/**
 * @author Kerry
 */

@Table
@Entity(name = "wx_develop_id")
@IdClass(WxDevelopIdEntity.WxDevelopIdEntityPK.class)
public class WxDevelopIdEntity {

    @Id
    private String appId;
    @Id
    private String secret;

    @Basic
    @Column(name = "last_time")
    private Long lastTime;

    @Basic
    @Column(name = "grant_type", length = 40)
    private String grantType;

    public String getAppId() {
        return appId;
    }

    public void setAppId(String appId) {
        this.appId = appId;
    }

    public String getSecret() {
        return secret;
    }

    public void setSecret(String secret) {
        this.secret = secret;
    }

    public Long getLastTime() {
        return lastTime;
    }

    public void setLastTime(Long lastTime) {
        this.lastTime = lastTime;
    }

    public String getGrantType() {
        return grantType;
    }

    public void setGrantType(String grantType) {
        this.grantType = grantType;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        WxDevelopIdEntity that = (WxDevelopIdEntity) o;

        if (appId != null ? !appId.equals(that.appId) : that.appId != null) return false;
        if (secret != null ? !secret.equals(that.secret) : that.secret != null) return false;
        if (lastTime != null ? !lastTime.equals(that.lastTime) : that.lastTime != null) return false;
        return grantType != null ? grantType.equals(that.grantType) : that.grantType == null;
    }

    @Override
    public int hashCode() {
        int result = appId != null ? appId.hashCode() : 0;
        result = 31 * result + (secret != null ? secret.hashCode() : 0);
        result = 31 * result + (lastTime != null ? lastTime.hashCode() : 0);
        result = 31 * result + (grantType != null ? grantType.hashCode() : 0);
        return result;
    }

    @Override
    public String toString() {
        return "WxDevelopIdEntity{" +
                "appId='" + appId + '\'' +
                ", secret='" + secret + '\'' +
                ", lastTime=" + lastTime +
                ", grantType='" + grantType + '\'' +
                '}';
    }

    public static class WxDevelopIdEntityPK implements Serializable {

        @Column(name = "appid", length = 40, nullable = false)
        private String appId;

        @Column(name = "secret", length = 60, nullable = false)
        private String secret;

        public WxDevelopIdEntityPK() {
        }

        public WxDevelopIdEntityPK(String appId, String secret) {
            this.appId = appId;
            this.secret = secret;
        }

        public String getAppId() {
            return appId;
        }

        public void setAppId(String appId) {
            this.appId = appId;
        }

        public String getSecret() {
            return secret;
        }

        public void setSecret(String secret) {
            this.secret = secret;
        }

        @Override
        public boolean equals(Object o) {
            if (this == o) return true;
            if (o == null || getClass() != o.getClass()) return false;

            WxDevelopIdEntityPK that = (WxDevelopIdEntityPK) o;

            if (appId != null ? !appId.equals(that.appId) : that.appId != null) return false;
            return secret != null ? secret.equals(that.secret) : that.secret == null;
        }

        @Override
        public int hashCode() {
            int result = appId != null ? appId.hashCode() : 0;
            result = 31 * result + (secret != null ? secret.hashCode() : 0);
            return result;
        }

        @Override
        public String toString() {
            return "WxDevelopIdEntityPK{" +
                    "appId='" + appId + '\'' +
                    ", secret='" + secret + '\'' +
                    '}';
        }
    }


}
